#include <stdint.h>

#define     MAX_PDU_ERR_FIFO_LEN     10   //fifo最大数量

static volatile int head = 0;
static volatile int last = 0;

static uint8_t l_fifo_list[MAX_PDU_ERR_FIFO_LEN] = {0}; //fifo列表

//命令推入fifo
int pdu_err_fifo_push (int errcode)
{
    if ((last+1)%MAX_PDU_ERR_FIFO_LEN == head) //队列已满
    {
        return -1;
    }
    /*l_fifo_list[last].cmd = cmd;*/
    l_fifo_list[last] = (uint8_t)errcode;
    last = (last+1)%MAX_PDU_ERR_FIFO_LEN;
    return 0;
}

//命令出fifo
int pdu_err_fifo_pop(void)
{
    int tmp;
    if (head == last)//队列已空
    {
        return -1;
    }
    tmp = (int)l_fifo_list[head];
    head = (head+1) % MAX_PDU_ERR_FIFO_LEN;
    return tmp;
}

